package com.mushuilingfeng.ddd.user.event;

import com.mushuilingfeng.ddd.framework.AsDomainEventSubscribe;
import com.mushuilingfeng.ddd.framework.event.IDomainEventListener;
import com.mushuilingfeng.ddd.user.domain.user.event.UserLockedEvent;
import com.mushuilingfeng.ddd.user.service.ITokenService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 沐水淋风
 * @date 2024/10/20
 */
@Slf4j
@AsDomainEventSubscribe(eventCls = UserLockedEvent.class)
@AllArgsConstructor
public class UserLockedEventSubscribe implements IDomainEventListener<UserLockedEvent> {
    private final ITokenService tokenService;
    
    @Override
    public void onEvent(UserLockedEvent event) {
        log.info("#UserLockedEventSubscribe#用户锁定事件");
        tokenService.invalidateUserToken(event.getUserId());
    }
    
}
